<?php
require('./roots.php');
require($root_path.'include/inc_environment_global.php');

# Set break file

# If cache must be deactivated, set $force_no_cache to true
$force_no_cache=1;

define('LANG_FILE','usuarios.php');
define('NO_2LEVEL_CHK',1);
require_once('include/inc_local_user.php');
require_once($root_path.'include/inc_front_chain_lang.php');
require_once($root_path.'include/care_api_classes/class_core.php');
$core=new Core;

 /**
 * LOAD Smarty
 */

require_once($root_path.'gui/smarty_template/smarty_care.class.php');
$smarty = new smarty_care('common');

if($parent_admit) $sTitleNr= ($_SESSION['sess_full_en']);
 else $sTitleNr = ($_SESSION['sess_full_pid']);

# Title in the toolbar
$action="usuario-buscar.php";
$msj = '';

global $_POST;
extract($_POST);

$login=$_SESSION['sess_login_userid'];

$searchprompt=$LDSearchWordPrompt;

$smarty->assign('action', $action);

$smarty->assign('searchprompt', $searchprompt);

$smarty->assign('sToolbarTitle',$LDBuscarUsuario);

$breakfile = 'usuarios.php' . URL_APPEND;
$smarty->assign('breakfile',$breakfile);

# Window bar title
$smarty->assign('title',$LDBuscarUsuario);

# Onload Javascript code
$smarty->assign('sOnLoadJs','onLoad="document.searchform.searchkey.select()"');

$sTemp = '';
ob_start();

include_once($root_path.'include/care_api_classes/class_usuario.php');
$u =new Usuario;

$usuarios = $u->getValueBy($login_id, $name);

if (!count($usuarios) && !strcmp($mode, "search"))
{
    $msj = "La búsqueda produjo 0 resultados.";
}
?>
<script language="javascript">
    function checkSubmit()
    {
        document.interconsulta.mode.value = "search";
        return true;
    }
</script>

<table cellspacing="1" cellpadding="2" border="0" align="center">
<?php
	# Load the usuarios
	if($usuarios != NULL){
?>
		<tr class="reg_list_titlebar">
			<td align="center">Nombre de usuario</td>
			<td align="center">Nombre y apellido</td>
			<td align="center">Tipo de usuario</td>
			<td align="center">Acción</td>
		</tr>
<?php
$pos=1;
foreach($usuarios as $usuario){
  ?>
  <tr class="wardlistrow<?=$pos?>">
    <td align="center"><?=$usuario['login_id']?></td>
    <td align="center"><?=$usuario['name']?></td>
    <td align="center"><?php
    if (strcmp($usuario['permission'], '_a_1_interinterconsultante') == 0) {
      echo "M&eacute;dico (Interconsultante)";
    } else if (strcmp($usuario['permission'], '_a_1_interinterconsultado') == 0) {
      echo "M&eacute;dico (Interconsultado)";
    } else if (strcmp($usuario['permission'], '_a_3_historiaauditor') == 0) {
      echo "Auditor";
    } else if (strcmp($usuario['permission'], '_a_2_intertriajewrite') == 0) {    } else if (strcmp($usuario['permission'], '_a_2_intertriajewrite') == 0) {
      echo "Triaje";
    } else if (strcmp($usuario['permission'], 'System_Admin') == 0) {
      echo "Administrador del sistema";
    }
    ?></td>
    <td align="center"><a href="<?=$root_path?>modules/usuarios/usuario-editar.php<?=URL_APPEND?>&login_id=<?=$usuario['login_id']?>"><input type="image" <?=createLDImgSrc($root_path,'ok_small.gif','0')?>  alt="Editar"/></a></td>
    </tr>
    <?php			
    
    if ($pos==1){$pos=2;
    }else{	$pos=1;	}
 }
	}

if($usuarios==NULL){
?>
		<h3 style="color:red;" ><?=$LDSinUsuarios?></h3>
<?php
	}
?>

</table>

	
<?php
$sTemp = ob_get_contents();
ob_end_clean();

$smarty->assign('sNombre', $LDNombre);
$smarty->assign('nombreInput', '<input type="text" name="name" value="' . $name . '">');

$smarty->assign('sLogin', $LDLogin);
$smarty->assign('loginInput', '<input type="text" name="login_id" value="' . $login_id . '">');

$smarty->assign('sHiddenInputs','<input type="image"'.createLDImgSrc($root_path,'searchlamp.gif','0','absmiddle').'><input type="hidden" name="lang" value="'.$lang.'"><input type="hidden" name="mode" value="">');

$smarty->assign('msj', $msj);

# Assign the buffer output  to main frame template
$smarty->assign('sMainDataBlock',$sTemp);
$smarty->assign('sMainBlockIncludeFile','usuarios/main.tpl');

 /**
 * show Template
 */
 $smarty->display('common/mainframe.tpl');


?>

